//
//  chatViewVoiceCell.m
//  AIM
//
//  Created by user10 on 2017/8/27.
//  Copyright © 2017年 user10. All rights reserved.
//

#import "chatViewVoiceCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>

#define screenWidth [UIScreen mainScreen].bounds.size.width
@implementation chatViewVoiceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if ( self ) {
        _longPressGesture =  [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(LongPress:)];
        self.timeL = [[UILabel alloc]init];
        self.timeL.numberOfLines = 0;
        [self.contentView addSubview:self.timeL];
        [self.timeL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.centerX.equalTo(self.contentView);
            make.width.mas_equalTo(screenWidth);
        }];
        self.timeL.textAlignment = NSTextAlignmentCenter;
        
        
        self.nameL = [[UILabel alloc]init];
        self.nameL.numberOfLines = 0;
        [self.contentView addSubview:self.nameL];
        [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.timeL.mas_bottom);
            make.right.mas_equalTo(self.contentView).offset(-15);
            make.width.mas_lessThanOrEqualTo(100);
        }];
        
        
        
        self.shopNameL = [[UILabel alloc]init];
        [self.contentView addSubview:self.shopNameL];
        [self.shopNameL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.nameL);
            make.right.mas_equalTo(self.nameL.mas_left).offset(-5);
            make.left.greaterThanOrEqualTo(self.contentView).offset(15);
        }];
        
        self.imgV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgV];
        [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.nameL.mas_bottom).offset(15);
            make.right.mas_equalTo(self.contentView).offset(-15);
            make.size.mas_equalTo(CGSizeMake(45, 45));
            make.bottom.lessThanOrEqualTo(self.contentView).offset(-15);
            
        }];
        
        self.photo = [[UIImageView alloc]init];
        [self.contentView addSubview:self.photo];
        [self.photo mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.imgV);
            make.right.mas_equalTo(self.imgV.mas_left).offset(-10);
            make.height.mas_equalTo(80);
            make.width.mas_equalTo(60);
            make.bottom.lessThanOrEqualTo(self.contentView).offset(-15);
        }];
        [self.photo setUserInteractionEnabled:YES];
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)LongPress:(UIGestureRecognizer *)recognizer{
    if ([self.delegate respondsToSelector:@selector(cellLongPress:)]) {
        // 调用代理对象的刷新方法，代理对象去实现方法
        [self.delegate cellLongPress:recognizer];
    }
}
@end
